package skipset

import (
	"sync/atomic"
	"unsafe"
)

type pointerArray [maxHeight]unsafe.Pointer

// 读取第 i 个指针
func (pa *pointerArray) load(i int) unsafe.Pointer {
	return pa[i]
}

// 存储第 i 个指针
func (pa *pointerArray) store(i int, p unsafe.Pointer) {
	pa[i] = p
}

// 原子读取第 i 个指针
func (pa *pointerArray) atomicLoad(i int) unsafe.Pointer {
	return atomic.LoadPointer(&pa[i])
}

// 原子存储第 i 个指针
func (pa *pointerArray) atomicStore(i int, p unsafe.Pointer) {
	atomic.StorePointer(&pa[i], p)
}
